#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int N = 2e5 + 10;
const ll mod = 1e9 + 7; 
ll a[N], f1[N], f2[N];

void solve()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i ++ ) cin >> a[i];
	f1[0] = abs(a[0]);
	f2[0] = a[0];
	for(int i = 1; i < n; i ++ )
	{
		f2[i] = f2[i - 1] + a[i];
		f1[i] = max(f1[i - 1] + a[i], abs(f2[i]));
	}
	cout << f1[n - 1] << endl;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	int T = 1;
	cin >> T;
	while(T --) solve();
	return 0;
}
